﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Epona.Domain.Query
{
    public abstract class BaseQuery
    {
        protected IRepository repository { private set; get; }
        private IQueryParameters parameters = PositionalParameters.Create();
        private NamedParameters mapParameters = NamedParameters.Create();
        public int FirstResult { private set; get; }
        public int MaxResults { private set; get; }

        public BaseQuery(IRepository repository)
        {
            this.repository = repository;
        }

        public IQueryParameters Parameters
        {
            get { return parameters; }
        }

        public BaseQuery SetParameters(object[] parameters)
        {
            this.parameters = PositionalParameters.Create(parameters);
            return this;
        }

        public BaseQuery SetParameters(IList<object>parameters)
        {
            this.parameters = PositionalParameters.Create(parameters);
            return this;
        }

        public BaseQuery SetParameters(Dictionary<string,object>parameters)
        {
            this.parameters = NamedParameters.Create(parameters);
            return this;
        }

        public BaseQuery SetFirstResult(int firstResult)
        {
            this.FirstResult = firstResult;
            return this;
        }

        public BaseQuery SetMaxResults(int maxResults)
        {
            this.MaxResults = maxResults;
            return this;
        }

        public abstract IList<T> List<T>();
        public abstract int ExecuteUpdate();

    }
}
